#pragma once

#include <QtCore/QString>

#include "Effect.hpp"

#include "D3D11Declarations.hpp"
#include "D3D11EffectTechnique.hpp"




namespace Engine
{
	namespace Video
	{
		class D3D11Effect
			: public Effect
		{
		public:

			SHARED(D3D11Effect)

			typedef std::pair<const std::string, D3D11EffectTechnique>           TechniquePair;
			typedef std::map<std::string, D3D11EffectTechnique>                  TechniqueMap;
			typedef boost::function<void (weak_ptr)>   DestroyedFn;

		protected:

			D3D11Effect(const DestroyedFn& destroyedFn, const ID3D11DevicePtr& device, const QString& name);
			void post_create(ptr _this);

		public:

			MAKE_SHARED3(D3D11Effect, DestroyedFn,ID3D11DevicePtr,QString);
			~D3D11Effect();



			/**
			 * Add a technique to this effect.
			 */
			EffectTechnique& addTechnique(const std::string& name);

			/**
			 * Optimize memory usage by freeing all reflection & compiled data.
			 */
			void optimize();



			/**
			 * Sends all API commands to draw the given RenderNode to the given context.
			 */
			void draw(D3D11DeviceContext& context, const RenderNode::ptr& node);

		private:

			weak_ptr                 m_this;
			DestroyedFn              m_destroyedFn;
			bool                     m_optimized;
			ID3D11DevicePtr          m_device;
			QString                  m_name;
			TechniqueMap             m_techniques;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
